package com.xueqiu.movieplaymanagersystem.entity;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author xueqiu
 * @Description: 评论表
 */
public class Comment implements Serializable {
    public static final Long serialVersionUID = 1L;

    /**
     * 评论ID
     */
    private String id;

    /**
     * 评论人昵称
     */
    @NotBlank(message = "评论人昵称不得为空")
    private String nickname;

    /**
     * 评论人email
     */
    @NotBlank(message = "评论人email不得为空")
    @Email(message = "评论人email格式错误")
    private String email;

    /**
     * 评论内容正文
     */
    @NotBlank(message = "评论内容正文不得为空")
    private String content;

    /**
     * 评论人头像URL
     */
    private String avatar;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 评论所属新闻ID
     */
    @NotBlank(message = "所属新闻id不得为空")
    private String blogId;

    /**
     * 回复此评论的所有的人的id；有许多所以用列表
     */
    private List<String> replyCommentsId;

    /**
     * 回复此评论的所有评论；有许多所以用列表
     */
    private List<Comment> replyComments = new ArrayList<>();

    /**
     * 上一级评论人ID
     */
    private String parentCommentId;

    /**
     * 上一级评论正文内容
     */
    private Comment parentComment;

    /**
     * 是否为博主
     */
    private boolean adminComment;

    /**
     * 上一级评论人昵称
     */
    private String parentNickname;

    public Long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getParentNickname() {
        return parentNickname;
    }

    public void setParentNickname(String parentNickname) {
        this.parentNickname = parentNickname;
    }

    public boolean getAdminComment() {
        return adminComment;
    }

    public void setAdminComment(boolean adminComment) {
        this.adminComment = adminComment;
    }

    public List<String> getReplyCommentsId() {
        return replyCommentsId;
    }

    public void setReplyCommentsId(List<String> replyCommentsId) {
        this.replyCommentsId = replyCommentsId;
    }

    public String getBlogId() {
        return blogId;
    }

    public void setBlogId(String blogId) {
        this.blogId = blogId;
    }

    public String getParentCommentId() {
        return parentCommentId;
    }

    public void setParentCommentId(String parentCommentId) {
        this.parentCommentId = parentCommentId;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public List<Comment> getReplyComments() {
        return replyComments;
    }

    public void setReplyComments(List<Comment> replyComments) {
        this.replyComments = replyComments;
    }

    public Comment getParentComment() {
        return parentComment;
    }

    public void setParentComment(Comment parentComment) {
        this.parentComment = parentComment;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Comment comment = (Comment) o;

        if (adminComment != comment.adminComment) {
            return false;
        }
        if (id != null ? !id.equals(comment.id) : comment.id != null) {
            return false;
        }
        if (nickname != null ? !nickname.equals(comment.nickname) : comment.nickname != null) {
            return false;
        }
        if (email != null ? !email.equals(comment.email) : comment.email != null) {
            return false;
        }
        if (content != null ? !content.equals(comment.content) : comment.content != null) {
            return false;
        }
        if (avatar != null ? !avatar.equals(comment.avatar) : comment.avatar != null) {
            return false;
        }
        if (createTime != null ? !createTime.equals(comment.createTime) : comment.createTime != null) {
            return false;
        }
        if (blogId != null ? !blogId.equals(comment.blogId) : comment.blogId != null) {
            return false;
        }
        if (replyCommentsId != null ? !replyCommentsId.equals(comment.replyCommentsId) : comment.replyCommentsId != null) {
            return false;
        }
        if (replyComments != null ? !replyComments.equals(comment.replyComments) : comment.replyComments != null) {
            return false;
        }
        if (parentCommentId != null ? !parentCommentId.equals(comment.parentCommentId) : comment.parentCommentId != null) {
            return false;
        }
        if (parentComment != null ? !parentComment.equals(comment.parentComment) : comment.parentComment != null) {
            return false;
        }
        return parentNickname != null ? parentNickname.equals(comment.parentNickname) : comment.parentNickname == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (content != null ? content.hashCode() : 0);
        result = 31 * result + (avatar != null ? avatar.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (blogId != null ? blogId.hashCode() : 0);
        result = 31 * result + (replyCommentsId != null ? replyCommentsId.hashCode() : 0);
        result = 31 * result + (replyComments != null ? replyComments.hashCode() : 0);
        result = 31 * result + (parentCommentId != null ? parentCommentId.hashCode() : 0);
        result = 31 * result + (parentComment != null ? parentComment.hashCode() : 0);
        result = 31 * result + (adminComment ? 1 : 0);
        result = 31 * result + (parentNickname != null ? parentNickname.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Comment{" +
                "id='" + id + '\'' +
                ", nickname='" + nickname + '\'' +
                ", email='" + email + '\'' +
                ", content='" + content + '\'' +
                ", avatar='" + avatar + '\'' +
                ", createTime=" + createTime +
                ", blogId='" + blogId + '\'' +
                ", replyCommentsId=" + replyCommentsId +
                ", replyComments=" + replyComments +
                ", parentCommentId='" + parentCommentId + '\'' +
                ", parentComment=" + parentComment +
                ", adminComment=" + adminComment +
                ", parentNickname='" + parentNickname + '\'' +
                '}';
    }
}
